<!-- page heading start-->
<div class="page-heading">
    <h3>
        层级管理
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">
                <a class="btn btn-default" href="/User/Member/classAdd">增加</a>
                <a class="btn btn-default" href="/User/Member/index">会员列表</a>
                <a class="btn btn-default" href="/User/Member/memberClass">层级管理</a>
                <a class="btn btn-default" href="/User/Member/service">会员服务</a>
                <a class="btn btn-default" href="/User/Member/property">会员扩展信息</a>
                <a class="btn btn-default" href="/User/Member/item">服务项目</a>
            </header>
            <div class="panel-body">
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="12%">层级名称</th>
                        <th width="10%">付费金额</th>
                        <th width="10%">添加时间</th>
                        <th width="10%">是否验证</th>
                        <th width="10%">会员服务</th>
                        <th width="10%">会员扩展信息</th>
                        <th width="12%">登录链接</th>
                        <th width="12%">注册链接</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span>
                                <?php echo $val['name'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['need_pay_money'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['added_time'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php
                                    if($val['need_check'] == 2){
                                        echo "否";
                                    }else{
                                        echo "是";
                                    }
                                ?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php
                                    $service_ids = explode(",", $val['service_ids']);
                                    if(!empty($service_ids)){
                                        $cond['service_id'] = array("IN",$service_ids);
                                        $service_list = M("member_service")->where($cond)->select();
                                        foreach($service_list as $service){
                                            echo $service['name'] . "<br>";
                                        }
                                    }
                                ?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php
                                    $property_ids = explode(",", $val['property_ids']);
                                    if(!empty($property_ids)){
                                        $cond['property_id'] = array("IN",$property_ids);
                                        $property_list = M("member_property")->where($cond)->select();
                                        foreach($property_list as $property){
                                            echo $property['name'] . "<br>";
                                        }
                                    }
                                ?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo "http://" . $_SERVER["HTTP_HOST"] . "/Wap/Member/login?id=" . $val['class_id'];?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo "http://" . $_SERVER["HTTP_HOST"] . "/Wap/Member/index?id=" . $val['class_id'];?>
                            </span>
                        </td>
                        <td>
                            <a class="btn btn-success"
                               href="<?php echo '/User/Member/classUpdate?type=update&classId=' . $val['class_id'];?>">编辑</a>
                            <a class="btn btn-default" href="#"
                               onclick="<?php echo 'return delete_data(' . $val['class_id'] .')';?>">删除</a>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>
<script>
    function delete_data(id){
        $.ajax({
            data:{classId:id},
            dataType:'json',
            url:'/User/Member/classDelete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
</script>